<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>

    <link rel="stylesheet" hrel="http://localhost/4.17/esri/css/main.css" />
    <script src="http://localhost/4.17/dojo/dojo.js"></script>
    <!-- 引用在线arcgis api -->
    <style>
        html,
        body,
        #viewDiv {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
        }
    </style>

    <script>
        require([
            "esri/Map",
            "esri/Basemap",
            "esri/views/MapView",
            "esri/views/SceneView",
            "esri/geometry/Extent",
            "esri/geometry/SpatialReference",
            //几何
            "esri/geometry/Point",
            "esri/geometry/Polyline",
            "esri/geometry/Polygon",
            "esri/Graphic",
            "esri/widgets/Sketch",
            "esri/Color",
            //切片地图信息
            "esri/layers/support/TileInfo",
            //图层
            "esri/layers/WebTileLayer",
            "esri/views/layers/LayerView",
            "esri/layers/TileLayer",
            "esri/layers/MapImageLayer",
            "esri/layers/FeatureLayer",
            "esri/layers/GraphicsLayer",
            //符号化
            "esri/symbols/SimpleMarkerSymbol",
            "esri/symbols/SimpleFillSymbol",
            "esri/symbols/SimpleLineSymbol",
            //缓冲参数，用于GeometryService
            "esri/tasks/support/BufferParameters",
            //几何处理，投影、简化、缓冲区
            "esri/tasks/GeometryService",
            //几何引擎，用于测试、测量和分析两个或多个二维几何图形之间的空间关系,缓冲、修剪、距离、相交、联合、面积距离计算等。
            "esri/geometry/geometryEngine",
            //代理
            "esri/core/urlUtils",
            //查询
            "esri/tasks/FindTask",
            "esri/tasks/support/FindParameters",
            "esri/tasks/QueryTask",
            "esri/tasks/support/Query",
            "esri/tasks/IdentifyTask",
            "esri/tasks/support/IdentifyParameters",
            //打印地图
            "esri/tasks/PrintTask",
            "esri/tasks/support/PrintTemplate",
            "esri/tasks/support/PrintParameters",
            "dojo/dom",
            "dojo/on",
            "dojo/domReady!"
        ], function(
            Map,
            Basemap,
            MapView,
            SceneView,
            Extent,
            SpatialReference,
            Point,
            Polyline,
            Polygon,
            Graphic,
            Sketch,
            Color,
            TileInfo,
            WebTileLayer,
            LayerView,
            TileLayer,
            MapImageLayer,
            FeatureLayer,
            GraphicsLayer,
            SimpleMarkerSymbol,
            SimpleFillSymbol,
            SimpleLineSymbol,
            BufferParameters,
            GeometryService,
            geometryEngine,
            urlUtils,
            FindTask,
            FindParameters,
            QueryTask,
            Query,
            IdentifyTask,
            IdentifyParameters,
            PrintTask,
            PrintTemplate,
            PrintParameters,
            dom,
            on) {
            var startExtent = new Extent({
                xmin: 120.236368,
                ymin: 36.043567,
                xmax: 120.579018,
                ymax: 36.196569,
                spatialReference: {
                    wkid: 4549
                }
            });
            var map = new Map({ //属性：allLayers、ground、layers
                basemap: "topo",
            });
            var view = new MapView({
                container: "viewDiv",
                map: map,
                zoom: 4,
                center: [55, 65] // longitude, latitude
            });
            var featureLayer = new FeatureLayer({
                url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"
            });
            const attributes = {};
            attributes["Des"] = "描述";
            attributes["Add"] = "China";
            attributes["Date"] = Data.now();

            const addFeature = new Graphic({
                geometry: geometry,
                attributes: attributes
            });
            //添加要素
            const promise = featureLayer.applyEdits({
                addFeatures: [addFeatures]
            });


            //添加附件
            function addAttachment(selectedFeature) {
                const blob = new Blob(byteArrays, {
                    type: "image/png"
                });
                addAttachments.push({
                    feature: selectedFeature,
                    attachment: {
                        globalId: "",
                        name: "",
                        data: blob
                    }
                });
                const edits = {
                    addAttachments: addAttachments
                };
                const options = {
                    globalIdUsed: true,
                    rollbackOnFailureEnabled: true
                };
                featureLayer.applyEdits(edits, options).then(function(result) {
                    console.log("edit added:", results);
                });
            }
        });
    </script>
</head>

<body>
    <div id="viewDiv">
    </div>

</body>

</html>
//DESKTOP-9DFAUNS:1521/orcl localhost //localhost:1521/orcl